package com.demo.mapper;

import com.demo.pojo.Worker;
import org.apache.ibatis.annotations.*;

public interface WorkerMapper {
    @Select("select * from tb_worker where id = #{id}")
    Worker selectWorker(int id);

    @Insert("insert into tb_worker(name,age,sex,worker_id) " +
            "values(#{name},#{age},#{sex},#{worker_id})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insertWorker(Worker worker);

    @Update("update tb_worker set name = #{name},age = #{age} where id = #{id}")
    int updateWorker(Worker worker);

    @Delete("delete from tb_worker where id = #{id}")
    int deleteWorker(int id);

    @Select("select * from tb_worker where id = #{id} and name = #{name}")
    Worker selectWorkerByIdAndName(@Param("id") int id,
            @Param("name") String name);

}

